import React from 'react'
import ReactDom from 'react-dom'
import {createStore, applyMiddleware, compose} from 'redux'
import en_US from 'antd/lib/locale-provider/en_US';
import thunk from 'redux-thunk'
import {Provider} from 'react-redux'
import {HashRouter, Route, Switch} from 'react-router-dom'
import {LocaleProvider} from 'antd'
import './globle.css';
import './img/icon/iconfont.css';
import reducers from './redux/reducer';
import './config';
import AuthFilter from './components/auth/authFilter';
import 'rc-texty/assets/index.css';
/*----新登陆----*/
import NewLogin from './containers/login/newLogin';
import Main from './containers/main/main';
/*--国际化--*/
import {addLocaleData, IntlProvider} from 'react-intl';
import en from 'react-intl/locale-data/en';
import {appLocale} from './locale/en_US';
import {sessionManager} from "./utils/sessionStorage";

addLocaleData([...en]);

const store = createStore(reducers, compose(
    applyMiddleware(thunk),
    window.devToolsExtension ? window.devToolsExtension() : f => f
))

sessionManager.set('locale','en');



ReactDom.render((
        <IntlProvider
            locale={appLocale.locale}
            messages={appLocale.messages}
            formats={appLocale.formats}
        >
            <LocaleProvider locale={en_US}>
                <Provider store={store}>
                    <HashRouter>
                        <div>
                            <AuthFilter/>
                            <Switch>
                                <Route path="/newLogin" component={NewLogin}/>
                                <Route path="/" component={Main}/>
                            </Switch>
                        </div>
                    </HashRouter>
                </Provider>
            </LocaleProvider>
        </IntlProvider>
    ), document.getElementById('en')
)